// import qs from 'qs'
const baseApi = '/api'
// const header = 'application/x-www-form-urlencoded'
const header = ''

export function initData (Axios, params) {
  return new Promise((resolve) => {
    Axios({
      headers: header,
      url: `${baseApi}/web/doAdd`,
      method: 'post',
      data: params
      // data: qs.stringify(param)
    }).then((res) => {
      resolve(res)
    }).catch((err) => {
      console.error(err)
    })
  })
}

/**
 * 服务端渲染请求方法
 * 1： {$axios} 发送和接收必须双花括号
 * 2. const $axios = this.$axios
        requestSsr({$axios},params).then(res=>{
          console.log(res,'=')
      })
 */
export function requestSsr ({ $axios }, params) {
  // return $axios({
  //   url: `${baseApi}/web/doAdd`,
  //   method: 'post',
  //   data:params
  // })
  return $axios.post(`${baseApi}/web/doAdd`, params) // 简写
}

/* export function getUserList ({$axios},params) {
  return $axios.get(`${baseApi}/userList`,{params})  //简写
} */
export function getUserList ({ $axios }, params) {
  return $axios.get('http://www.phonegap100.com/appapi.php?a=getPortalList&catid=20', { params }) // 简写
}

export function noUserList ({ $axios }, params) {
  return $axios.post(`${baseApi}/erro2`, { params })
}
